home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-admin / link-import.php < prev    next >
Encoding:
PHP Script  |  2005-03-15  |  4.8 KB  |  132 lines

  1. <?php
  2. // Links
  3. // Copyright (C) 2002 Mike Little -- mike@zed1.com
  4.  
  5. require_once('admin.php');
  6. $parent_file = 'link-manager.php';
  7. $title = __('Import Blogroll');
  8. $this_file = 'link-import.php';
  9.  
  10. $step = $_POST['step'];
  11. if (!$step) $step = 0;
  12. ?>
  13. <?php
  14. switch ($step) {
  15.     case 0:
  16.     {
  17.         include_once('admin-header.php');
  18.         if ($user_level < 5)
  19.             die (__("Cheatin’ uh?"));
  20.  
  21.         $opmltype = 'blogrolling'; // default.
  22. ?>
  23.  
  24. <div class="wrap">
  25.  
  26.     <h2><?php _e('Import your blogroll from another system') ?> </h2>
  27.     <!-- <form name="blogroll" action="link-import.php" method="get"> -->
  28.     <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
  29.  
  30.     <ol>
  31.     <li><?php _e('Go to <a href="http://www.blogrolling.com">Blogrolling.com</a> and sign in. Once you’ve done that, click on <strong>Get Code</strong>, and then look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr> code</strong>') ?>.</li>
  32.     <li><?php _e('Or go to <a href="http://blo.gs">Blo.gs</a> and sign in. Once you’ve done that in the \'Welcome Back\' box on the right, click on <strong>share</strong>, and then look for the <strong><abbr title="Outline Processor Markup Language">OPML</abbr> link</strong> (favorites.opml).') ?></li>
  33.     <li><?php _e('Select that text and copy it or copy the link/shortcut into the box below.') ?><br />
  34.        <input type="hidden" name="step" value="1" />
  35.        <?php _e('Your OPML URL:') ?> <input type="text" name="opml_url" size="65" />
  36.     </li>
  37.     <li>
  38.        <?php _e('<strong>or</strong> you can upload an OPML file from your desktop aggregator:') ?><br />
  39.        <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
  40.        <label><?php _e('Upload this file:') ?> <input name="userfile" type="file" /></label>
  41.     </li>
  42.  
  43.     <li><?php _e('Now select a category you want to put these links in.') ?><br />
  44.     <?php _e('Category:') ?> <select name="cat_id">
  45. <?php
  46.     $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
  47.     foreach ($categories as $category) {
  48. ?>
  49.     <option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
  50. <?php
  51.         } // end foreach
  52. ?>
  53.     </select>
  54.  
  55.     </li>
  56.  
  57.     <li><input type="submit" name="submit" value="<?php _e('Import!') ?>" /></li>
  58.     </ol>
  59.     </form>
  60.  
  61. </div>
  62. <?php
  63.                 break;
  64.             } // end case 0
  65.  
  66.     case 1: {
  67.                 include_once('admin-header.php');
  68.                 if ($user_level < 5)
  69.                     die (__("Cheatin' uh ?"));
  70. ?>
  71. <div class="wrap">
  72.  
  73.      <h2><?php _e('Importing...') ?></h2>
  74. <?php
  75.                 $cat_id = $_POST['cat_id'];
  76.                 if (($cat_id == '') || ($cat_id == 0)) {
  77.                     $cat_id  = 1;
  78.                 }
  79.  
  80.                 $opml_url = $_POST['opml_url'];
  81.                 if (isset($opml_url) && $opml_url != '') {
  82.                     $blogrolling = true;
  83.                 }
  84.                 else // try to get the upload file.
  85.                 {
  86.                     $uploaddir = get_settings('fileupload_realpath');
  87.                     $uploadfile = $uploaddir.'/'.$_FILES['userfile']['name'];
  88.  
  89.                     if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
  90.                     {
  91.                         //echo "Upload successful.";
  92.                         $blogrolling = false;
  93.                         $opml_url = $uploadfile;
  94.                     } else {
  95.                         echo __("Upload error");
  96.                     }
  97.                 }
  98.  
  99.                 if (isset($opml_url) && $opml_url != '') {
  100.                     $opml = implode('', file($opml_url));
  101.                     include_once('link-parse-opml.php');
  102.  
  103.                     $link_count = count($names);
  104.                     for ($i = 0; $i < $link_count; $i++) {
  105.                         if ('Last' == substr($titles[$i], 0, 4))
  106.                             $titles[$i] = '';
  107.                         if ('http' == substr($titles[$i], 0, 4))
  108.                             $titles[$i] = '';
  109.                         $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
  110.                                 VALUES('{$urls[$i]}', '".addslashes($names[$i])."', '', $cat_id, '".addslashes($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
  111.                         $result = $wpdb->query($query);
  112.                         echo sprintf(__("<p>Inserted <strong>%s</strong></p>"), $names[$i]);
  113.                     }
  114. ?>
  115.      <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
  116. <?php
  117.                 } // end if got url
  118.                 else
  119.                 {
  120.                     echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n";
  121.                 } // end else
  122.  
  123. ?>
  124. </div>
  125. <?php
  126.                 break;
  127.             } // end case 1
  128. } // end switch
  129. ?>
  130. </body>
  131. </html>
  132.